// To parse this JSON data, do
//
//     final commentData = commentDataFromJson(jsonString);

import 'dart:convert';

CommentData commentDataFromJson(String str) =>
    CommentData.fromJson(json.decode(str));

String commentDataToJson(CommentData data) => json.encode(data.toJson());

class CommentData {
  CommentData({
    this.id,
    this.commentType,
    this.usersLike,
    this.content,
    this.commentObjId,
    this.commentObjUserId,
    this.commentUserId,
    this.commentId,
    this.createdTime,
    this.updatedTime,
    this.v,
    this.userInfo,
    this.replyList,
  });

  String id;
  int commentType;
  List<dynamic> usersLike;
  String content;
  String commentObjId;
  String commentObjUserId;
  String commentUserId;
  String commentId;
  DateTime createdTime;
  DateTime updatedTime;
  int v;
  UserInfo userInfo;
  List<ReplyList> replyList;

  factory CommentData.fromJson(Map<String, dynamic> json) => CommentData(
        id: json["_id"],
        commentType: json["comment_type"],
        usersLike: List<dynamic>.from(json["users_like"].map((x) => x)),
        content: json["content"],
        commentObjId: json["comment_obj_id"],
        commentObjUserId: json["comment_obj_user_id"],
        commentUserId: json["comment_user_id"],
        commentId: json["comment_id"],
        createdTime: DateTime.parse(json["created_time"]),
        updatedTime: DateTime.parse(json["updated_time"]),
        v: json["__v"],
        userInfo: UserInfo.fromJson(json["user_info"]),
        replyList: List<ReplyList>.from(
            json["reply_list"].map((x) => ReplyList.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "_id": id,
        "comment_type": commentType,
        "users_like": List<dynamic>.from(usersLike.map((x) => x)),
        "content": content,
        "comment_obj_id": commentObjId,
        "comment_obj_user_id": commentObjUserId,
        "comment_user_id": commentUserId,
        "comment_id": commentId,
        "created_time": createdTime.toIso8601String(),
        "updated_time": updatedTime.toIso8601String(),
        "__v": v,
        "user_info": userInfo.toJson(),
        "reply_list": List<dynamic>.from(replyList.map((x) => x.toJson())),
      };
}

class ReplyList {
  ReplyList({
    this.id,
    this.commentType,
    this.replyCommentUserAvatar,
    this.replyCommentUserName,
    this.usersLike,
    this.content,
    this.commentObjId,
    this.replyCommentUserid,
    this.commentId,
    this.createdTime,
    this.updatedTime,
    this.replyId,
    this.v,
  });

  String id;
  int commentType;
  String replyCommentUserAvatar;
  String replyCommentUserName;
  List<dynamic> usersLike;
  String content;
  String commentObjId;
  String replyCommentUserid;
  String commentId;
  String replyId;
  DateTime createdTime;
  DateTime updatedTime;
  int v;

  factory ReplyList.fromJson(Map<String, dynamic> json) => ReplyList(
        id: json["_id"],
        commentType: json["comment_type"],
        replyCommentUserAvatar: json["reply_comment_user_avatar"],
        replyCommentUserName: json["reply_comment_user_name"],
        usersLike: List<dynamic>.from(json["users_like"].map((x) => x)),
        content: json["content"],
        commentObjId: json["comment_obj_id"],
        replyCommentUserid: json["reply_comment_userid"],
        commentId: json["comment_id"],
        replyId:json["reply_id"],
        createdTime: DateTime.parse(json["created_time"]),
        updatedTime: DateTime.parse(json["updated_time"]),
        v: json["__v"],
      );

  Map<String, dynamic> toJson() => {
        "_id": id,
        "comment_type": commentType,
        "reply_comment_user_avatar": replyCommentUserAvatar,
        "reply_comment_user_name": replyCommentUserName,
        "users_like": List<dynamic>.from(usersLike.map((x) => x)),
        "content": content,
        "comment_obj_id": commentObjId,
        "reply_comment_userid": replyCommentUserid,
        "comment_id": commentId,
        "created_time": createdTime.toIso8601String(),
        "updated_time": updatedTime.toIso8601String(),
        "__v": v,
      };
}

class UserInfo {
  UserInfo({
    this.id,
    this.userId,
    this.token,
    this.phoneNumber,
    this.createdAt,
    this.updatedAt,
    this.v,
    this.avatar,
    this.nickname,
  });

  String id;
  String userId;
  String token;
  String phoneNumber;
  DateTime createdAt;
  DateTime updatedAt;
  int v;
  String avatar;
  String nickname;

  factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
        id: json["_id"],
        userId: json["userId"],
        token: json["token"],
        phoneNumber: json["phoneNumber"],
        createdAt: DateTime.parse(json["createdAt"]),
        updatedAt: DateTime.parse(json["updatedAt"]),
        v: json["__v"],
        avatar: json["avatar"],
        nickname: json["nickname"],
      );

  Map<String, dynamic> toJson() => {
        "_id": id,
        "userId": userId,
        "token": token,
        "phoneNumber": phoneNumber,
        "createdAt": createdAt.toIso8601String(),
        "updatedAt": updatedAt.toIso8601String(),
        "__v": v,
        "avatar": avatar,
        "nickname": nickname,
      };
}
